<template>
  <div id="login_id">
    <div class="box">
      <div class="zzz">
        <div class="top">优质甄选 高枕无忧</div>
        <div class="from">
          <input
            type="text"
            placeholder="请输入您的用户名"
            v-model.trim="form_data.username"
          /><br />
          <input
            type="password"
            placeholder="请输入您的密码"
            v-model.trim="form_data.password"
          /><br />
          <button @click="submit">登录</button>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      form_data: {
        username: "admin",
        password: "admin888",
      },
    };
  },
  methods: {
    submit() {
      if (this.form_data.username == "") {
        return alert("用户名不能为空");
      }
      if (this.form_data.password == "") {
        return alert("密码不能为空");
      }
      this.$http.post("/api/userlogin", this.form_data).then((res) => {
        if (res.code == 200) {
          var login_data = JSON.stringify(res.list);
          localStorage.setItem("login_data", login_data);
          this.$router.replace("/index");
        }
      });
    },
  },
};
</script>

<style>
#login_id {
  width: 100%;
  height: 100vh;
  background-image: linear-gradient(to bottom, #ff5d3e, #eb8b7a);
}
.box {
  width: 600px;
  height: 600px;
  position: absolute;
  right: 200px;
  top: 100px;
  background: url("../../../资料包/小U商城后台管理系统参考效果/小U商城后台管理系统参考效果/img/loginbg.a14bd0f6.png")
    no-repeat center center;
  background-size: 100%;
}
.zzz {
  width: 300px;
  height: 400px;
  position: absolute;
  top: 120px;
  right: 25px;
}
.top {
  width: 300px;
  height: 100px;
  background: url("../../../资料包/小U商城后台管理系统参考效果/小U商城后台管理系统参考效果/img/logo.926d2fa6.png")
    no-repeat center center;
  background-size: 100%;
  text-align: center;
  line-height: 250px;
  letter-spacing: 10px;
  color: #aaa8a8;
}
.from {
  width: 300px;
  margin-top: 90px;
}
.from input {
  width: 90%;
  border: none;
  border-bottom: 1px solid #ff5d3e;
  outline: none;
  background-color: #fff4f2;
  line-height: 30px;
  margin-bottom: 30px;
  padding: 10px;
}
.from button {
  width: 100%;
  border: none;
  background-color: #ff5d3e;
  color: #fff;
  outline: none;
  line-height: 30px;
  border-radius: 15px;
  margin-bottom: 40px;
}
</style>